import {
  BwComPropSetConstValueComEnum,
  BwCustomComSoltTypeEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'allowClear',
    name: '支持清除	',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autoClearSearchValue',
    name: '是否选中后清空搜索框',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'autofocus',
    name: '默认获取焦点',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'bordered',
    name: '是否有边框',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: '	true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'defaultActiveFirstOption',
    name: '是否默认高亮第一个选项',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'defaultOpen',
    name: '是否默认展开下拉菜单',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'disabled',
    name: '是否禁用',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'popupClassName',
    name: '下拉菜单的 className 属性',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'dropdownMatchSelectWidth',
    name: '下拉菜单和选择器同宽',
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.boolean,
      BwCustomComPropDataTypeEnum.number,
    ],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'dropdownMenuStyle',
    name: 'dropdown 菜单自定义样式',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'dropdownRender',
    name: '自定义下拉框内容',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.function],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.function,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'dropdownStyle',
    name: '下拉菜单的 style 属性',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'fieldNames',
    name: '自定义节点 label、value、options 的字段',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValue: JSON.stringify({
      label: 'label',
      value: 'value',
      options: 'options',
    }),
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'filterOption',
    name: '是否根据输入项进行筛选',
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.boolean,
      // BwCustomComPropDataTypeEnum.function,
    ],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'filterSort',
    name: '搜索时对筛选结果项的排序函数',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.function],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.function,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'firstActiveValue',
    name: '默认高亮的选项',
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
      BwCustomComPropDataTypeEnum.function,
    ],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'getPopupContainer',
    name: '菜单渲染父节点',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.function],
    // defaultValue: '() => document.body',
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.function,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'labelInValue',
    name: '是否把每个选项的 label 包装到 value 中',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'false',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'listHeight',
    name: '设置弹窗滚动高度',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValue: '256',
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'maxTagCount',
    name: '最多显示多少个 tag',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'maxTagPlaceholder',
    name: '隐藏 tag 时显示的内容',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'maxTagTextLength',
    name: '最大显示的 tag 文本长度',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'mode',
    name: '设置 Select 的模式为多选或标签',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '多选',
          value: 'multiple',
        },
        {
          label: '标签',
          value: 'tags',
        },
        {
          label: '组合框',
          value: 'combobox',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'notFoundContent',
    name: '当下拉列表为空时显示的内容',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'Not Found',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'open',
    name: '是否展开下拉菜单',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'optionFilterProp',
    name: '搜索时过滤对应的 option 属性，不支持 children',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'value',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'optionLabelProp',
    name: '回填到选择框的 Option 的属性值',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'children ',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'options',
    name: 'options 数据',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValue: '[]',
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'placeholder',
    name: '选择框默认文字',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'placement',
    name: '选择框弹出的位置',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'bottomLeft',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: 'bottomLeft',
          value: 'bottomLeft',
        },
        {
          label: 'bottomRight',
          value: 'bottomRight',
        },
        {
          label: 'topLeft',
          value: 'topLeft',
        },
        {
          label: 'topRight',
          value: 'topRight',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'searchValue',
    name: '控制搜索文本',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showArrow',
    name: '是否显示下拉小箭头',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'showSearch',
    name: '配置是否可搜索',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'size',
    name: '选择框大小',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: 'default',
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '大',
          value: 'large',
        },
        {
          label: '中',
          value: 'default',
        },
        {
          label: '小',
          value: 'small',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'status',
    name: '设置校验状态',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '错误',
          value: 'error',
        },
        {
          label: '警告',
          value: 'warning',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'tagRender',
    name: '自定义 tag 内容 render',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.function],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.function,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'tokenSeparators',
    name: '自动分词的分隔符',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.array],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.array,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'value',
    name: 'value(v-model)',
    isModel: true,
    isRequire: false,
    dataType: [
      BwCustomComPropDataTypeEnum.array,
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.number,
    ],
    defaultValue: undefined,
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'virtual',
    name: '是否使用虚拟滚动',
    isRequire: false,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValue: 'true',
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:value',
    name: '绑定Value',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '绑定值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
  {
    key: 'blur',
    name: '失去焦点的时回调',
    params: [],
  },
  {
    key: 'change',
    name: '选中 option，或 input 的 value 变化（combobox 模式下）时的回调',
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
      {
        paramKey: 'option',
        paramName: '选项',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'deselect',
    name: '取消选中时的回调',
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
      {
        paramKey: 'option',
        paramName: '选项',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'dropdownVisibleChange',
    name: '展开下拉菜单的回调',
    params: [
      {
        paramKey: 'open',
        paramName: '是否展开',
        paramDataType: BwCustomComEmitParamDataTypeEnum.boolean,
        remark: '',
      },
    ],
  },
  {
    key: 'focus',
    name: '获得焦点时回调',
    params: [],
  },
  {
    key: 'inputKeyDown',
    name: '键盘按下时回调',
    params: [],
  },
  {
    key: 'mouseenter',
    name: '鼠标移入时回调',
    params: [],
  },
  {
    key: 'mouseleave',
    name: '鼠标移出时回调',
    params: [],
  },
  {
    key: 'popupScroll',
    name: '下拉列表滚动时的回调',
    params: [],
  },
  {
    key: 'search',
    name: '文本框值变化时回调',
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
  {
    key: 'select',
    name: '被选中时的回调',
    params: [
      {
        paramKey: 'value',
        paramName: '值',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
      {
        paramKey: 'option',
        paramName: '选项',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'clearIcon',
      slotName: '自定义的多选框清空图标',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'maxTagPlaceholder',
      slotName: '隐藏 tag 时显示的内容',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'menuItemSelectedIcon',
      slotName: '自定义当前选中的条目图标',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'notFoundContent',
      slotName: '当下拉列表为空时显示的内容',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'option',
      slotName: '通过 option 插槽，自定义节点',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'removeIcon',
      slotName: '自定义的多选框清除图标',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'suffixIcon',
      slotName: '自定义的选择框后缀图标',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'tagRender',
      slotName: '自定义 tag 内容 render',
    },
  },
]

export const antSelectInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
